package org.yx.service.sres.view_device_maintain_item_detail;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.utils.BaseService;

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 查询某设备的维护保养项目明细
 * 
 * @author zxw
 * @since 2019/09/01
 **/
public class SresViewDeviceMaintainItemDetailService extends BaseService {
	public SresViewDeviceMaintainItemDetailOut viewDeviceMaintainItemDetail(SresViewDeviceMaintainItemDetailIn in)
			throws Exception {
		if (StrUtil.isBlank(in.getResId())) {
			return new SresViewDeviceMaintainItemDetailOut();
		}

		Query query = new Query(in.getPageIndex(), in.getPageSize());
		query.addFilter("orgCode", in.getUserOrgCode());
		query.addFilter("resId", in.getResId());
		if (StrUtil.isNotBlank(in.getItemCode())) {
			query.addFilter("itemCode", in.getItemCode());
		}

		Page<DeviceMaintainItem> itemPage = selectPageBySqlFilePath("select_device_maintain_item_detail", query,
				DeviceMaintainItem.class);

		SresViewDeviceMaintainItemDetailOut out = new SresViewDeviceMaintainItemDetailOut();
		out.setItemList(itemPage.getList());
		out.setTotal(itemPage.getTotalSize());

		return out;
	}
}